package com.lagou.code.controller;

import com.lagou.code.service.IAuthCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * created by kirito at 2020/7/12
 */
@RestController
@RequestMapping("/api/code")
public class AuthCodeController {

    @Autowired
    private IAuthCodeService authCodeService;

    @GetMapping("/create/{email}")
    public void createCode(@PathVariable(value = "email") String email) {
        authCodeService.createCode(email);
    }

    @GetMapping("/validate/{email}/{code}")
    public int validateCode(@PathVariable(value = "email") String email,
                                 @PathVariable(value = "code") String code) {
        return authCodeService.validateCode(email, code);
    }
}
